import Cookies from 'js-cookie'

const TokenKey = 'ticket'
const UserKey = 'adminUser'
const userNameKey = 'userName'
const RoutersKey = 'filterRouter'

export function getToken () {
    return Cookies.get(TokenKey)
}

export function setToken (token) {
    return Cookies.set(TokenKey, token)
}

export function removeToken () {
    return Cookies.remove(TokenKey)
}
export function getUser () {
    return Cookies.get(UserKey)
}
export function setUser (user) {
    return Cookies.set(UserKey, user)
}
export function getUserName () {
    return Cookies.get('userName')
}
export function setUserName (userName) {
    return Cookies.set(userNameKey, encodeURIComponent(userName), {path: ''})
}
export function removeUser () {
    return Cookies.remove(UserKey)
}
export function setRouters (routers) {
    return Cookies.set(RoutersKey, JSON.stringify(routers))
}
export function getRouters () {
    return JSON.parse(Cookies.get(RoutersKey))
}
